



use actix_web::web;
use handlers::general::health_check_handler;
use handlers::course::{get_course_detail, get_course_for_teacher, new_course};
use handlers::teacher::{get_all_teacher, get_teacher_details, post_new_teacher};
use handlers::teacher::{delete_teacher, update_teacher_details};
use crate::routers::handlers::course::{delete_course, update_course_details};

#[path="handlers/mod.rs"]
pub mod handlers;

// use crate::handlers::health_check_handler;

// #[path = "."]
// mod handles;
//
// use handles::*;
// use crate::handlers::course::{get_course_detail, get_course_for_teacher, new_course};
// use crate::handlers::general::health_check_handler;



#[warn(dead_code)]
pub fn general_routes(cfg: &mut web::ServiceConfig) {
    // cfg.route("/health", web::get().to(health_check_handler));
    cfg.route("/health", web::get().to(health_check_handler));
}
pub fn course_routes(cfg: &mut web::ServiceConfig) {
    cfg
        // .service(web::scope("/course"))
        .route("/course/",web::post().to(new_course))
        .route("/course/{user_id}",web::get().to(get_course_for_teacher))
        .route("/{user_id}/{course_id}",web::get().to(get_course_detail))
        .route("/{teacher_id}/{course_id}",web::delete().to(delete_course))
        .route("/{teacher_id}/{course_id}",web::put().to(update_course_details));
}

pub fn teacher_routes(cfg: &mut web::ServiceConfig) {
    cfg.service(web::scope("/teacher")
        .route("/",web::post().to(post_new_teacher))
        .route("/",web::get().to(get_all_teacher))
        .route("/{teacher_id}",web::get().to(get_teacher_details))
        .route("/{teacher_id}",web::put().to(update_teacher_details))
        .route("/{teacher_id}",web::delete().to(delete_teacher)));
}






// #[cfg(test)]
// mod tests {
//     use std::ptr::write_bytes;
//     use super::*;
//     use actix_web::http::{ StatusCode};
//     use std::sync::Mutex;
//     use crate::models::Course;
//     use crate::state::AppState;
//
//     #[actix_rt::test]
//     async fn post_course_test(){
//         let course = web::Json(Course{
//             teacher_id: 1,
//             name: "The test course".into(),
//             id: None,
//             time: None,
//         });
//         let app_state: web::Data<AppState> = web::Data::new(AppState{
//             courses: Mutex::new(vec![]),
//             visit_count: Mutex::new(0),
//             health_check_response: ".".to_string()
//         });
//         let resp = new_course(course, app_state).await;
//         assert_eq!(resp.status(), StatusCode::OK);
//     }
// }








